'\"macro stdmacro
.\"
.\" Copyright (c) 2022 Ken McDonell.  All Rights Reserved.
.\"
.\" This program is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License as published by the
.\" Free Software Foundation; either version 2 of the License, or (at your
.\" option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful, but
.\" WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
.\" or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
.\" for more details.
.\"
.\"
.TH PMATRYDELTAINDOM 3 "PCP" "Performance Co-Pilot"
.SH NAME
\f3pmaTryDeltaInDom\f1 \- try to translate a physical indom record from a ``full indom'' to a ``delta indom''
.SH "C SYNOPSIS"
.ft 3
.ad l
.hy 0
#include <pcp/pmapi.h>
.br
#include <pcp/libpcp.h>
.br
#include <pcp/archive.h>
.sp
int pmaTryDeltaInDom(__pmLogCtl *\fIlcp\fP,
'in +\w'int pmaTryDeltaInDom('u
__int32_t\ **\fIrbuf\fP,
__pmLogInDom\ *\fIlidp\fR);
.in
.sp
cc ... \-lpcp_archive \-lpcp
.hy
.ad
.ft 1
.SH CAVEAT
This documentation is intended for internal Performance Co-Pilot
(PCP) developer use.
.PP
These interfaces are not part of the PCP APIs that are guaranteed to
remain fixed across releases, and they may not work, or may provide
different semantics at some point in the future.
.SH DESCRIPTION
.de CR
.ie t \f(CR\\$1\fR\\$2
.el \fI\\$1\fR\\$2
..
The input instance domain is passed in as either a
physical metadata record via
.I rbuf
or in the ``loaded'' format identified by
.IR lidp .
As these are alternate formats for the input instance domain,
.B pmaTryDeltaInDom
demands that
.B exactly
one of
.I rbuf
and
.I lidp
must be
.BR NULL ,
else the return value is -2.
.PP
The input instance domain is on
the path to being written to the archive identified by
.IR lcp .
.PP
If possible, the instance domain will be converted to the ``delta indom''
format, and the converted instance domain returned via
.I rbuf
or
.I lidp
(whichever is not
.BR NULL ).
If conversion takes place, any storage associated with the input instance domain
will have been free'd.
.PP
The ``delta indom'' format is only supported for Version 3 archives and it
is the caller's responsibility to determine if calling
.B pmaTryDeltaInDom
is appropriate.
.PP
To determine if the ``delta indom'' format is the most efficient encoding,
.B pmaTryDeltaInDom
maintains a per-instance domain cache of the last seen ``full''
instance domain.
To avoid data corruption, this means
.B pmaTryDeltaInDom
first copies
the input instance domain.
The copy and the cache are all managed privately by
.B pmaTryDeltaInDom
so the caller is unaware of this activity.
.PP
The caching scheme requires that the caller must call
.B pmaTryDeltaInDom
for
.B every
instance domain record, independent of whether the ``delta indom'' format
is likely to be appropriate.
.SH DIAGNOSTICS AND RETURN VALUES
In several places, fatal errors will trigger an error message and
force the application to exit.
.PP
A return value of -1 indicates that
.I rbuf
was not
.B NULL
and the physical record therein
was not a
.B TYPE_INDOM
(Version 3 ``full'' instance domain) record as expected.
A return value of 1 means
.I rbuf
or
.I lidp
has been rewritten, and is now a
.B TYPE_INDOM_DELTA
record.
Otherwise the return value is 0.
.SH SEE ALSO
.BR pmaDeltaInDom (3),
.BR PMAPI (3)
and
.BR pmaUndeltaInDom (3).
